package com.abel.bigwater.wflow.file

import com.abel.bigwater.model.ticket.LossTicket
import java.io.InputStream

interface PhotoBucket {
    /**
     * 保存照片，并返回full-path without server end-point.
     */
    fun putPhoto(dirName: String?, photoName: String?, pin: InputStream?): String?

    /**
     * 获取照片的URI
     * @param full path of photo but no server end-point.
     */
    fun visitPhoto(fullPath: String?): String?
}

/**
 * 将相对路径修改为URI。
 */
fun LossTicket.encodePath(pb: PhotoBucket?) {
    findPhoto1 = pb?.visitPhoto(findPhoto1)
    findPhoto2 = pb?.visitPhoto(findPhoto2)
    findPhoto3 = pb?.visitPhoto(findPhoto3)
    findPhoto1b = pb?.visitPhoto(findPhoto1b)
    findPhoto2b = pb?.visitPhoto(findPhoto2b)
    findPhoto3b = pb?.visitPhoto(findPhoto3b)

    fixPhoto1 = pb?.visitPhoto(fixPhoto1)
    fixPhoto2 = pb?.visitPhoto(fixPhoto2)
    fixPhoto3 = pb?.visitPhoto(fixPhoto3)
    fixPhoto1b = pb?.visitPhoto(fixPhoto1b)
    fixPhoto2b = pb?.visitPhoto(fixPhoto2b)
    fixPhoto3b = pb?.visitPhoto(fixPhoto3b)
    fixPhoto1c = pb?.visitPhoto(fixPhoto1c)
    fixPhoto2c = pb?.visitPhoto(fixPhoto2c)
    fixPhoto3c = pb?.visitPhoto(fixPhoto3c)
}